import w_md5 from "@/js_sdks/w_md5.js";
import {
    version,
    deviceType,
    salt
} from '@/config/config.js';
import store from '@/store'

export const getMd5 = () => {
    const t = (new Date()).getTime();
    const lang = store.state.lang;

    let gs = ''; // device-type=pcversion=1.0.0ts=1657519847986lang=zhCNsalt=marsbox_web!@#$
    gs += "device-type=" + deviceType;
    gs += "ts=" + t;
    gs += "version=" + version;
    gs += "lang=" + lang;
    gs += "salt=" + salt;

    const m = w_md5.hex_md5_32(gs); // md5加密
    const sign = m.substr(m.length - 8) + m.substr(8, m.length - 16) + m.substr(0, 8); // 将字符串前后8位互换位置组成新字符串

    return {
        'device-type': deviceType,
        ts: t,
        version: version,
        lang: lang,
        sign: sign,
    }
}